****** Figure_6_2:  Harbors and Democracy (Country-level), Predicted Values
use data/Demo_book_country_3.dta, clear
* polyarchy, 100-point scale
gen v2x_polyarchy_100 = (v2x_polyarchy / .924) * 100

* polyarchy, missing obs imputed
impute v2x_polyarchy lexical_index inc_chall_combined , gen(v2x_polyarchy_imp)
* 100-point scale
replace v2x_polyarchy_imp = v2x_polyarchy_imp * 100
gen v2x_polyarchy_imp_100 = (v2x_polyarchy_imp / 92.4) * 100
replace v2x_polyarchy_imp_100 = . if sovereign_Cojocaru ==.


qui reg v2x_polyarchy_imp_100 predallports53_100km i.year if year > 1959, vce(cluster country_id)
qui margins, at(predallports53_100km=(0(5)20)) 
marginsplot, ysc(r(0(10)100)) ylabel(0(10)100) ytitle("Polyarchy index", size(small)) ylabel(,nogrid) xtitle("Distance to Natural Harbor (100 km)", size(small)) title("Predictive Margins with 95% CIs", color(black) size(medium)) recast(line) recastci(rarea) ciopts(color(gs8)) plotopts(lc(black)) graphregion(color(white))
graph export "Figure_6_2.png", replace
capture graph export "output/Figure_6_2.pdf", replace
capture graph export "output/Figure_6_2.eps", replace
